-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controller helpers #56
Conversation
@hiddeco, @seaneagan: is this useful enough to be worth persevering, wdyt? |
I think that with our comments addressed it would be really useful to get good Kubernetes events and metadata rich notifications. So, yes! |
a21e69c
to
2144df2
Compare
408ae15
to
5eaace5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hidde, your commit messages are a joy 🥭
This adds a struct which can be embedded in a reconciler, which contains the metrics recording logic. Signed-off-by: Michael Bridgen <michael@weave.works>
This adds the capability of sending events to Kubernetes and the notification controller. Signed-off-by: Michael Bridgen <michael@weave.works>
This commit adds support for providing a reason to the Event method, and maps the severity of an event to a K8s core event type. This makes the emitted events in-line with Kubernetes standards, and is beneficial to the Flux UI: fluxcd/webui#13 The reason to not fully depend on the K8s event type and drop the severity is because there have been reports from users wanting to have access to "debug" events, a type not known to Kubernetes. Signed-off-by: Hidde Beydals <hello@hidde.co>
To allow recording metrics for conditions other than just the readiness status. The `RecordReadinessMetric` method is kept in place for API consumption convenience. Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit addresses the two rough edges mentioned by Michael. > You have to supply an ObjectReference to both the metrics and the > events methods. As the helper methods are always called from within a reconciler, and both events and metrics must only be recorderd for well known resources, the methods of the helpers should only be called for objects that do contain data about the kind and/or version. This means that calling `reference.GetReference` within the helper methods will generally not result in any errors, nor be a really expensive calculation. In cases where the GVK information for some reason is not available on the object, `GetReference` will still be capable of falling back to the manager's `runtime.Scheme` that is now injected to the helper. Resulting in a - in my personal opinion - fair trade-off, and a much more friendly API from the consumer's perspective. > You have to pass logs in to the Events helper. By relying on the context of the reconcile operation we get a logger (with object metadata preconfigured) for free. Signed-off-by: Hidde Beydals <hello@hidde.co>
Signed-off-by: Hidde Beydals <hello@hidde.co>
This is an experimental PR to see if some of the bits common to all the GOTK controllers can be factored out into embeddable structs.
Among other things, this will
It is a bit rough around the edges:
You have to supply an ObjectReference to both the metrics and the events methods. This is because all the constituent bits calculated this for themselves, and had different ways of dealing with errors. This way, the error handling is done once, up front, and the ref only has to be calculated once. But it would be nice to do this behind the scenes, in some way.
You have to pass logs in to the Events helper. This is a bit awkward, as getting logs to funcs always is. It'd be nice if the setup could just do this for you.